//
//  BaseViewController.m
//  hsy
//
//  Created by Les on 14-3-3.
//  Copyright (c) 2014年 Les. All rights reserved.
//

#import "BaseViewController.h"
#import "ChildViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*) reuqest navigationType:(UIWebViewNavigationType)navigationType{
    
    NSURL* url = [reuqest URL];
    if([[url scheme] isEqualToString:@"close"]){
        [self.navigationController popViewControllerAnimated:YES];
        return NO;
    }else if([[url scheme] isEqualToString:@"showchildwebview"]){
        NSUserDefaults *accountDefaults = [NSUserDefaults standardUserDefaults];
        [accountDefaults setObject:[NSString stringWithFormat:@"%@%@",[url host],[url path]] forKey:@"childPath"];
        
        ChildViewController* child = [[ChildViewController alloc]initWithNibName:@"ChildViewController" bundle:nil];
        [self.navigationController pushViewController:child animated:YES];
//        [self performSegueWithIdentifier:@"showChild" sender:self];
        return NO;
    }
    
    
    return YES;
}

-(void)webViewDidStartLoad:(UIWebView*)webView{
    
}


-(void)webViewDidFinishLoad:(UIWebView*)webView {
    
}

-(void)webView:(UIWebView*)webView  DidFailLoadWithError:(NSError*)error{
    
}

@end
